package com.zzu.wardrobe.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.HibernateTemplate;

import com.zzu.wardrobe.dao.ClothesDAO;
import com.zzu.wardrobe.entity.Clothes;

public class ClothesDAOImpl implements ClothesDAO{

	private HibernateTemplate hibernateTemplate;
	private Clothes clothes;
	
	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}

	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}

	public Clothes getClothes() {
		return clothes;
	}

	public void setClothes(Clothes clothes) {
		this.clothes = clothes;
	}

	@Override
	public List<Clothes> showAll() {
		String hql = "from Clothes";
		return hibernateTemplate.find(hql);
	}

	@Override
	public int add(Clothes clothes) {
		try{
		hibernateTemplate.save(clothes);
	    return 1;
		}catch(Exception e){
			System.out.println(e);
			return 0 ;
		}
	}

}
